{extend name="public/base" /}

{block name="title"} 后臺首頁--新增<?php echo '<?=$title?>'?>{/block}

{block name="style"}{/block}

{block name="main"}


<!-- /section:basics/sidebar -->

<div class="page-content">

	<!-- /section:settings.box -->
	<div class="page-content-area">

		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->

				<div class="page-header">
					<h1>
						<?php echo'<?=$title?>'?>
					</h1>
				</div>

				<div class="row">
					<div class="col-sm-12">
						<!-- #section:elements.tab -->
						<div class="tabbable">
							<ul class="nav nav-tabs" id="myTab">
								<li class="">
									<a href="/<?=$routeName?>_lst">
										<i class="fa fa-align-justify bigger-120"></i>
										<?=$config['tableCnName']?>列表
									</a>
								</li>

								<li class="active">
									<a href="/<?=$routeName?>_add">
										<i class="fa fa-plus green bigger-120"></i>
										新增<?=$config['tableCnName']?>
									</a>
								</li>
							</ul>

						</div>

						<!-- /section:elements.tab -->
					</div><!-- /.col -->

				</div>


				<div class="hr hr-18 dotted hr-double" style="border:none;"></div>

				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->
						<form class="form-horizontal" id="conform" role="form" action="" method="post">

<?php
     foreach($config['form_fields'] as $k=>$v){
		if(!isset($v['type']) || $v['type'] == '' || $k=='parent_id'){
			continue;
		}
?>
						<?php if($v['type'] == 'text'){ ?>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <?=$v['text']?>：</label>
								<div class="col-sm-9">
                                        <span class="input">
                                        <input type="text" name="<?=$k?>" value="<?php echo '<?php echo $data[\''.$k.'\']?>';?>" <?=$v['validate']?> placeholder="<?=$v['placeholder']?>" class="col-xs-10 col-sm-5">
                                        </span>
									<span class="Validform_checktip"></span>
								</div>

							</div>
							<div class="space-4"></div>
						<?php }elseif($v['type'] == 'password'){?>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <?=$v['text']?>：</label>
								<div class="col-sm-9">
                                        <span class="input">
                                        <input type="password" name="<?=$k?>" <?=$v['validate']?> placeholder="<?=$v['placeholder']?>" class="col-xs-10 col-sm-5">
                                        </span>
									<span class="Validform_checktip"></span>
								</div>

							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <?=$v['text']?>：</label>
								<div class="col-sm-9">
                                        <span class="input">
                                        <input type="password" name="re<?=$k?>" recheck="<?=$k?>" <?=$v['validate']?> placeholder="<?=$v['placeholder']?>" class="col-xs-10 col-sm-5">
                                        </span>
									<span class="Validform_checktip"></span>
								</div>

							</div>
							<div class="space-4"></div>

							<?php }elseif($v['type'] == 'file'){ ?>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 上传图片：</label>
								<div class="col-sm-9">
									<div class="test">
										<div class="up-button" id="select-img">选择图片</div>
										<div class="img-list" id="img-list">
											<!--图片列表样例-->
											<div class="img-item">
												<?php echo '<?=showImage($data[\''.$k.'\'])?>';?>
												<input type="hidden" name="imgs[]" />
												<em class="delete" onclick="uploader.del_list(this)">×</em>
											</div>

										</div>
									</div>
								</div>
							</div>
							<div class="space-4"></div>

						<?php }elseif($v['type'] == 'textarea'){ ?>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="limited"><?=$v['text']?>：</label>
								<div class="col-sm-9">
									<div class="pos-rel">
										<textarea name="<?=$k?>" class="form-control limited autosize-transition" id="limited" maxlength="50" style="overflow: hidden; word-wrap: break-word; resize: horizontal;width:45%; height: 52px;"><?php echo '<?php echo $data[\''.$k.'\']?>';?></textarea>
									</div>
									<span class="Validform_checktip"></span>
								</div>
							</div>

						<?php }elseif($v['type'] == 'checkbox'){ ?>
							<div class="form-group pri_id">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-tags"><?=$v['text']?>：</label>
								<div class="col-sm-9">
									<div class="select col-sm-4">
										<?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1):?>

										<div class="checkbox inline">
											<label>
												<input name="<?=$k?>[]" value="<?=$k1?>" class="ace ace-checkbox-2" type="checkbox" <?php if($k1==0){echo $v['validate'];}?>>
												<span class="lbl"><?=$v1?></span>
											</label>
										</div>
										<?php endforeach;}?>
									</div>
									<span class="Validform_checktip Validform-checkbox"></span>
								</div>
							</div>
							<div class="space-4"></div>

						<?php  }elseif($v['type'] == 'radio'){ ?>
							<div class="form-group pri_id">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-tags"><?=$v['text']?>：</label>
								<div class="col-sm-9">
									<div class="select col-sm-4">
										<?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1){?>
										<div class="radio inline">
											<label>
												<input name="<?=$k?>" value="<?=$k1?>" <?php if($k1==0){echo $v['validate'];}?> class="ace" type="radio">
												<span class="lbl"><?=$v1?></span>
											</label>
										</div>
										<?php }} ?>
									</div>
									<span class="Validform_checktip"></span>
								</div>
							</div>
							<div class="space-4"></div>

						<?php }else if($v['type'] == 'select'){ ?>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-tags"><?=$v['text']?>：</label>
								<div class="col-sm-9">
                                            <span class="select col-sm-3" style="padding-left:0;">
                                            <select class="form-control" <?=$v['validate']?> name="<?=$k?>">
                                                <option value="0">请选择</option>
												<?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1):?>
                                                <option value="<?=$k1?>"><?=$v1?></option>
												<?php endforeach;}?>
                                            </select>
                                            </span>
									<span class="Validform_checktip"></span>

								</div>
							</div>
						<?php } ?>
					<?php } ?>

							<div class="clearfix form-actions">
								<div class="col-md-offset-3 col-md-9">
									<input type="hidden" name="<?=$pri_key?>" value="<?php echo '<?php echo $data[\''.$pri_key.'\']?>';?>" ?>
									<button class="btn btn-info" type="submit">
										<i class="ace-icon fa fa-check bigger-110"></i>
										立即送出
									</button>

									&nbsp; &nbsp; &nbsp;
									<button class="btn" type="reset">
										<i class="ace-icon fa fa-undo bigger-110"></i>
										重置
									</button>
								</div>
							</div>


						</form>

					</div><!-- /.col -->
				</div>

			</div><!-- /.col -->
		</div><!-- /.row -->
	</div><!-- /.page-content-area -->
</div><!-- /.page-content -->



{/block}

{block name="js"}
<script>
	var demo = $("#conform").Validform({
		tiptype:2,
		<?php if(isset($config['has_checkbox']) && $config['has_checkbox'] == 1 ) {?>
		datatype:{
			'need2':function(gets,obj,curform,regxp){
				var need=1,
						numselected=curform.find("input[name='"+obj.attr("name")+"']:checked").length;
				if(numselected >= need){
					$('.pri_id').find('.Validform-checkbox').removeClass('Validform_wrong').addClass('Validform_right');
					$('.pri_id').find('.Validform-checkbox').text("通过验证");
					return true;
				}else{
					$('.pri_id').find('.Validform-checkbox').addClass('Validform_wrong');
					$('.pri_id').find('.Validform-checkbox').text("请至少选择"+need+"项！");
					return false;
				}
			},
		}
		<?php } ?>

		/*
        tiptype:function(msg,o,cssctl){
            if(o.type == 3) {
                C.alert(msg);
            }
        },
        */
		//tipSweep:true,

	});

	<?php if(isset($config['has_file']) && $config['has_file'] == 1 ) {?>
	$('#select-img').click(function(){
		//alert(123);
		uploader.open({
			elm:'select-img',//选择图片上传的按钮
			url:"<?=url('comm/ajax/uploader','',false)?>",//服务器url
			up_type:1,//上传图片类型1:单图,2:多图
			img_list:'img-list',//存放选择图片之后的容器
			input_name:'<?=$config["file_name"]?>',//上传图片表单ID
			img_num:6,//多图上传的总数
			num:2
		});
	});
	<?php } ?>

</script>
{/block}